﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Microsoft.VisualBasic;

namespace SalePartial.Model
{

    public class XPFavoriteVedorInfo
    {
        // Methods
        public XPFavoriteVedorInfo()
        {
            this._companyID = Guid.Empty;
            this._vendorID = Guid.Empty;
            this._folderID = Guid.Empty;
            this._comment = string.Empty;
            this._createDate = DateTime.Now;
            this._lastSaveDate = DateTime.MinValue.AddYears(0x76c);
            this._deleteDate = DateTime.MinValue.AddYears(0x76c);
        }

        public XPFavoriteVedorInfo(SqlDataReader reader)
        {
            this._companyID = Guid.Empty;
            this._vendorID = Guid.Empty;
            this._folderID = Guid.Empty;
            this._comment = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPFavoriteVedorInfo(int id)
        //{
        //    this._companyID = Guid.Empty;
        //    this._vendorID = Guid.Empty;
        //    this._folderID = Guid.Empty;
        //    this._comment = string.Empty;
        //    SqlDataReader reader = XPFavoriteVedorUtility.SelectReader(id);
        //    if (reader.Read())
        //    {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    }
        //    else
        //    {
        //        if (!reader.IsClosed)
        //        {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPFavoriteVedors does not exist.");
        //    }
        //}


        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._favorID = reader.GetInt32(0);
                this._companyID = reader.GetGuid(1);
                this._vendorID = reader.GetGuid(2);
                this._folderID = reader.GetGuid(3);
                if (!reader.IsDBNull(4))
                {
                    this._createDate = reader.GetDateTime(4);
                }
                if (!reader.IsDBNull(5))
                {
                    this._lastSaveDate = reader.GetDateTime(5);
                }
                if (!reader.IsDBNull(6))
                {
                    this._deleteDate = reader.GetDateTime(6);
                }
                if (!reader.IsDBNull(7))
                {
                    this._comment = reader.GetString(7);
                }
            }
        }


        // Properties
        public string Comment
        {
            get { return this._comment; }
            set { this._comment = value; }
        }

        public Guid CompanyID
        {
            get { return this._companyID; }
            set { this._companyID = value; }
        }

        public DateTime CreateDate
        {
            get { return this._createDate; }
            set { this._createDate = value; }
        }

        public DateTime DeleteDate
        {
            get { return this._deleteDate; }
            set { this._deleteDate = value; }
        }

        public int FavorID
        {
            get { return this._favorID; }
            set { this._favorID = value; }
        }

        public Guid FolderID
        {
            get { return this._folderID; }
            set { this._folderID = value; }
        }

        public DateTime LastSaveDate
        {
            get { return this._lastSaveDate; }
            set { this._lastSaveDate = value; }
        }

        public Guid VendorID
        {
            get { return this._vendorID; }
            set { this._vendorID = value; }
        }


        // Fields
        private string _comment;
        private Guid _companyID;
        private DateTime _createDate;
        private DateTime _deleteDate;
        private int _favorID;
        private Guid _folderID;
        private DateTime _lastSaveDate;
        private Guid _vendorID;
    }


}
